#ifndef DEXELFIELD_HPP
#define DEXELFIELD_HPP

#include <vector>
#include <map>

#include "dexel.hpp"
#include "point.hpp"
#include "cutter.hpp"


using std::map;
using std::vector;




class dexelfield //full space of dexels
{
  
public:
  typedef inter_dexel ourdexel;
  
  dexelfield();
  
  dexelfield(double _xmin, double _ymin, //generate empty space of desired size
	     long _nx, long _ny,
	     double _dx, double _dy);
      
  void blank(double xmin, double xmax,  //make solid box of desired size
	     double ymin, double ymax,
	     double zmin, double zmax,
	     double dx, double dy );

  void adddexel(long ix,long iy,ourdexel d);
  
  
  body_state state(double x, double y, double z);
  body_state state(long ix, long iy, double z);
  
  double intersect_x(double,double,double,double);
  double intersect_y(double,double,double,double);
  double intersect_z(double,double,double,double);

  long referx(double x) const;
  long refery(double y) const;

  double unrefx(long ix);
  double unrefy(long iy);
  

  void apply_cutter(cutter*);
  
  
  long hash(long ix,long iy) const;

  long hash(double x, double y) const;

  //  double updatezmin();
  //  double updatezmax();
  
  
  double
    xmin, xmax,
    ymin, ymax,
    zmin, zmax,
    dx, dy;

  long nx;

  // map<long,dexel> f;
  vector<ourdexel> f;
  
};

#endif
